<!-- 本题目要求： -->
<!-- 请使用至少 4 种方式将 div 中的 span 元素 左右居中，上下居中 -->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1,
        .box2,
        .box3,
        .box4 {
            width: 100%;
            height: 100px;
            margin-bottom: 20px;
        }

        .box1 {
            background-color: yellowgreen;
        }

        .box2 {
            background-color: darkorange;
        }

        .box3 {
            background-color: darkcyan;
        }

        .box4 {
            background-color: darkslateblue;
        }


        /* 第一种 */
        /* .box1,
        .box2,
        .box3,
        .box4 {
            display: flex;
            align-items: center;
            justify-content: center;
        } */

        
        /* 第二种 */
        /* .box1,
        .box2,
        .box3,
        .box4 {
            position: relative;
        }

        .box1 span,
        .box2 span,
        .box3 span,
        .box4 span {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        } */

        /* 第三种 */
        /* .box1,
        .box2,
        .box3,
        .box4 {
            display: table;
        }

        .box1 span,
        .box2 span,
        .box3 span,
        .box4 span {
            display: table-cell;
            text-align: center;
            vertical-align: middle;
        } */


        /* 第四种 */
        /* body {
            display: grid;
            place-items: center;
        }

        .box1 span,
        .box2 span,
        .box3 span,
        .box4 span {
            justify-self: center;
            align-self: center;
        } */
    </style>
</head>

<body>
    <div class="box1">
        <span>center</span>
    </div>
    <div class="box2">
        <span>center</span>
    </div>
    <div class="box3">
        <span>center</span>
    </div>
    <div class="box4">
        <span>center</span>
    </div>
</body>

</html>